<template>
  <div id="RoomPriceSetting">
    <div class="content">
      <p>通知设置</p>
      <div class="noticeSetting">
        <div class="noticeSetting_item">
          <div class="noticeSetting_item_left">
            <div>订单消息弹框</div>
            <div>订单落单、变更、取消时，有系统弹框提醒</div>
          </div>
          <div class="noticeSetting_item_right">
            <el-switch v-model="messageConfig.message_dialog" @change="changePopup" inactive-color="#ff4949"> </el-switch>
          </div>
        </div>
        <div class="noticeSetting_item">
          <div class="noticeSetting_item_left">
            <div>订单消息声音提醒</div>
            <div>订单落单、变更、取消时，有系统声音播报</div>
          </div>
          <div class="noticeSetting_item_right">
            <el-switch v-model="messageConfig.message_volice" @change="changeSound" inactive-color="#ff4949"></el-switch>
          </div>
        </div>
      </div>


    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'

export default {
  computed: {
    ...mapState('d2admin/message', [
      'messageConfig',
    ])
  },
  data() {
    return {
      openSound: false,//声音提醒
      openMessage: false,//弹框提醒
    }
  },
  methods: {
    ...mapActions('d2admin/message', [
      'getMessageConfig',
    ]),
    changePopup(v) {
      this.changeMessageConfig('message_dialog', v)

    },
    changeSound(v) {
      this.changeMessageConfig('message_volice', v)
    },
    /**
     * 改变配置
     * @param {*} type message_dialog 或者 message_volice
     */
    changeMessageConfig(type, status) {
      let data = {
        hotel_id: sessionStorage.getItem('hotel_id'),
        type,
        status: status ? 1 : 0
      }
      // console.log(data,'data');
      this.my_request('supplier/hotel-pms-message', data, 'PUT').then(res => {
        // console.log(res, '改变消息通知配置结果');
        // 1 开启  0 关闭
        let { code, data } = res.data
        if (200 == code) {
          this.getMessageConfig()
        }
      })
    }
  },
  watch: {},
  created() {
    this.getMessageConfig()
  },
  mounted() {
  },

}
</script>

<style lang="scss" scoped>
.content {
  width: calc(100% - 40px);
  height: calc(100% - 40px);
  padding: 20px;
}

.noticeSetting {
  width: 100%;
  height: 100%;
  background-color: white;
  margin-top: 20px;


  .noticeSetting_item {
    border: 1px solid #DCDFE6;
    width: calc(100% - 80px);
    padding: 10px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .noticeSetting_item_left {
      div:nth-child(1) {
        font-size: 16px;
      }

      div:nth-child(2) {
        font-size: 14px;
        line-height: 25px;
      }
    }
  }
}
</style>